home *** CD-ROM | disk | FTP | other *** search
- #ifndef lint
- static char SccsId[] = "@(#)view_merge.c V1.10 3/13/95";
- #endif
- /*
- | file name - view_merge.c
- |
- |===================================================================
- |
- | This program combines two previously saved views into
- | one larger view. The flag DS_EXACT_MATCH used in the
- | subroutine TviMergeAddDataSources prevents a data source
- | in the second view from overwriting a data source in the
- | first view with the same name.
- |
- | The user can specify the device names and the views to be
- | merged and the output view.
- |
- | The defaults are DVDEVICE upper.v, lower.v and merged.v
- |
- | The newly created view will be displayed and update until the
- | user "QUITS" with the q-key or the right mouse button.
- |
- |===================================================================
- */
- #include "std.h"
- #include "dvstd.h"
- #include "dvtools.h"
- #include "Tfundecl.h"
- #include "VOfundecl.h"
-
- int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow )
- {
- INT argc;
- char **argv;
-
- /*
- argv[1] - display device (default DVDEVICE)
- argv[2] - first view file (default upper.v)
- argv[3] - second view file (default is lower.v)
- argv[4] - new view file (default is merged.v)
- */
-
- OBJECT screen, location;
- VIEW view, view1, view2;
- DATASOURCELIST masterdsl;
- DRAWPORT drawport;
- int key;
-
- argc = 0;
- /* use value of DVPATH config var */
- make_argv(&argc,&argv,GetCommandLine());
- TInit ((char *) NULL, (char *) NULL);
-
- /* Open the display device */
- if (argc > 1)
- screen = TscOpenSet (argv[1], (char *) NULL,
- V_X_EXPOSURE_BLOCK, YES, V_END_OF_LIST);
- else
- screen = TscOpenSet ((char *) NULL, (char *) NULL,
- V_X_EXPOSURE_BLOCK, YES, V_END_OF_LIST);
- if (!screen)
- {
- printf ("Must specify device on command line or");
- printf (" in DataViews configuration file.\n");
- exit (EXIT_ERR);
- }
-
- if (argc > 3)
- {
- /* Load two views and create the new one */
- view1 = TviLoad (argv[2]);
- view2 = TviLoad (argv[3]);
- }
- else
- {
- /* Load two views and create the new one */
- view1 = TviLoad ("upper.v");
- view2 = TviLoad ("lower.v");
- }
-
- view = TviCreate ();
-
- /* Merge the datasources into the new view */
- masterdsl = TviGetDataSourceList (view);
- TviMergeAddDataSources (view1, masterdsl, DS_EXACTMATCH);
- TviMergeAddDataSources (view2, masterdsl, DS_EXACTMATCH);
-
- /* Merge the drawings into the new view */
- TviMergeDrawing (view, TviGetDrawing (view1));
- TviMergeDrawing (view, TviGetDrawing (view2));
-
- /* Display the new view */
- drawport = TdpCreate (screen, view,
- (RECTANGLE *) NULL, (RECTANGLE *) NULL);
-
- TdlOpenData (masterdsl);
- TdlReadData (masterdsl);
- TdpDraw (drawport);
-
- key = '\n';
- while ((key != 'q') && (key != 3))
- {
- TdlReadData (masterdsl);
- TdpDrawNext (drawport);
- location = TloPoll (PICK_POLL);
- if (location)
- key = VOloKey (location);
- }
-
- /* Save the merged view */
- if (argc > 4)
- {
- TviSave (view, argv[4]);
-
- /* Print success message and exit */
- printf ("File '%s' created - ", argv[4]);
- printf ("use DV-Draw or DV-Play to display.\n");
- }
- else
- {
- TviSave (view, "merged.v");
-
- /* Print success message and exit */
- printf ("File 'merged.v' created - ");
- printf ("use DV-Draw or DV-Play to display.\n");
- }
-
- /*
- * Erase the screen, free the dynamic data structures, close the
- * display device, and terminate DV-Tools.
- */
- TscErase (screen);
- TdpDestroy (drawport);
- TdlCloseData (masterdsl);
- TviDestroy (view);
- TviDestroy (view1);
- TviDestroy (view2);
- TscCloseCurrentScreen ();
- TTerminate ();
- return (EXIT_OK);
- }
-